package com.briup.cms.web.controller;

import com.briup.cms.service.ICommentService;
import com.briup.cms.utils.Message;
import com.briup.cms.utils.MessageUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@Api(tags = "评论管理相关接口")
@RestController
@RequestMapping("/auth/comment")
public class CommentController {

    @Autowired
    private ICommentService service;

    @ApiOperation("分页查询栏目")
    @GetMapping("/pageQuery")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "pageNum",value = "当前页",dataType = "int",required = true),
            @ApiImplicitParam(name = "pageSize",value = "页面大小",dataType = "int",required = true)})
    public Message queryPage(int pageNum, int pageSize){

        return MessageUtil.success(service.pageQueryAll(pageNum,pageSize));
    }

    @ApiOperation("/更新状态")
    @PutMapping("/check")
    public Message updateCommentByStatus(int id , int status){
        service.updateCommentByStatus(id,status);
        return MessageUtil.success("更新成功");
    }

    @ApiOperation("/通过ID删除")
    @DeleteMapping("/deleteById")
    public Message delectById(int id){
        service.deleteById(id);
        return MessageUtil.success("删除成功");
    }
}
